package com.itheima.manager;

import cn.hutool.core.collection.CollectionUtil;
import com.itheima.domain.db.Questionnaire;
import com.itheima.domain.db.SoulQuestion;
import com.itheima.domain.db.SoulQuestionOption;
import com.itheima.service.db.QuestionnaireService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class QuestionnaireManager {

    @Reference
    private QuestionnaireService questionnaireService;

    // 查询问卷列表
    public PageBeanVo findQuestionnaireList(Integer pageNum, Integer pageSize) {
        return questionnaireService.findQuestionnaireAllByPage(pageNum,pageSize);
    }


    public PageBeanVo findQuestionListById(Integer id, Integer pageNum, Integer pageSize) {
        return questionnaireService.findQuestionListById(id,pageNum,pageSize);
    }

    // 删除问题
    public void deleteQuestionById(Long id) {
        questionnaireService.deleteQuestionById(id);
    }

    public PageBeanVo findQuestionOptionById(Integer questionId, Integer pageNum, Integer pageSize) {
        return questionnaireService.findQuestionOptionById(questionId,pageNum,pageSize);
    }

    // 问题选项数据回显
    public SoulQuestionOption findQuestionOptionInfoById(Long questionQptionId) {
        return questionnaireService.findQuestionOptionInfoById(questionQptionId);
    }


    public void saveQuestionOptionInfo(Long id, String content, Integer score) {
        questionnaireService.saveQuestionOptionInfo(id,content,score);
    }

    // 删除问题选项
    public void deleteQuestionOptionById(Long questionOptionId) {
        questionnaireService.deleteQuestionOptionById(questionOptionId);
    }

    // 添加问题
    public void saveQuestion(String id, String question, String[] option, Integer[] score, Integer[] extroversion, Integer[] judgement, Integer[] abstraction, Integer[] rationality) {
        // 添加题目// 添加问题选项
        SoulQuestion soulQuestion = new SoulQuestion();
        soulQuestion.setQuestion(question);
        soulQuestion.setQuestionnaireId(Integer.parseInt(id));
        questionnaireService.saveQuestion(soulQuestion,option,score,extroversion,judgement,abstraction,rationality);
    }

    // 添加问题的选项
    public void saveQuestionOption(SoulQuestionOption soulQuestionOption) {
        questionnaireService.saveQuestionOption(soulQuestionOption);
    }

    // 添加问题
    /*public void saveQuestion(String id, String question, String optionA, String optionB, String scoreA, String scoreB, String optionC, String optionD, String scoreC, String scoreD) {
        // 添加题目// 添加问题选项
        SoulQuestion soulQuestion = new SoulQuestion();
        soulQuestion.setQuestion(question);
        soulQuestion.setQuestionnaireId(Integer.parseInt(id));
        questionnaireService.saveQuestion(soulQuestion,optionA,optionB,scoreA,scoreB,optionC,optionD,scoreC,scoreD);
    }*/
}
